<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.swim.entity.SkillRequest"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>SWIM</title>
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'/>
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<script type='text/javascript'>
		function checkNotEmpty(description, id) {

			if (description.value == "") {
				alert("You have to describe the new skill!");

				description.focus();
			} else {
				var form = document.createElement("form");
				form.setAttribute("method", "post");
				form.setAttribute("action", "newfb.jsp");

				var hiddenField = document.createElement("input");
				hiddenField.setAttribute("type", "hidden");
				hiddenField.setAttribute("name", "desc");
				hiddenField.setAttribute("value", description.value);
				form.appendChild(hiddenField);

				var star1 = document.getElementById('star1');
				var star2 = document.getElementById('star2');
				var star3 = document.getElementById('star3');
				var star4 = document.getElementById('star4');
				var star5 = document.getElementById("star5");
				var rating = "0";
				if(star5.checked)
					rating = "5";
				else if(star4.checked)
					rating = "4";
				else if(star3.checked)
					rating = "3";
				else if(star2.checked)
					rating = "2";
				else if(star1.checked)
					rating = "1";
				else {
					alert("You didn't rate!");
					return;
				}
				alert(rating);
				
				hiddenField = document.createElement("input");
				hiddenField.setAttribute("type", "hidden");
				hiddenField.setAttribute("name", "rating");
				hiddenField.setAttribute("value", rating);
				form.appendChild(hiddenField);

				hiddenField = document.createElement("input");
				hiddenField.setAttribute("type", "hidden");
				hiddenField.setAttribute("name", "id");
				hiddenField.setAttribute("value", id);
				form.appendChild(hiddenField);

				document.body.appendChild(form);
				form.submit();
			}

		}
	</script>

</head>
<body>
<%
	Object admin = request.getSession().getAttribute("admin");
	%>
	<div id="menu-wrapper">
		<div id="menu">
			<ul>
				<li><a href="index.jsp">Homepage</a></li>
				<li><a href="collaboration.jsp">Collaborations</a></li>
				<li><a href="friends.jsp">Friends</a></li>
				<li><a href="edit.jsp">Edit Profile</a></li>
				<li><a href="logout.jsp">Logout</a></li>
				
				<%if (admin == null || !(Boolean) admin) {
				%>	
				<li><a href="newskillreq.jsp">Request Skill</a></li>
				<%} else {
				%>	
				<li><a href="newskill.jsp">Create Skill</a></li>
				<%}%>
				
			</ul>
		</div>
		<!-- end #menu -->
	</div>

<div id="wrapper">
	<div id="header-wrapper">
		<div id="header">
			<div id="logo">
				<h1><a href="#">SWIM</a></h1>
				<p>"A social network for friends needing or offering help"</p>
			</div>
		</div>
	</div>
	<!-- end #header -->
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<h2 class="title">New Feedback</h2>
						
						<div class="entry">

							<fieldset class="rating">
								<legend>Rating:</legend>
								<input type="radio" id="star5" name="rating" value="5" />
									<label for="star5" title="Rocks!">5 stars</label> 
								<input type="radio" id="star4" name="rating" value="4" />
										<label for="star4" title="Pretty good">4 stars</label> 
								<input type="radio" id="star3" name="rating" value="3" />
									<label for="star3" title="Meh">3 stars</label> 
								<input type="radio" id="star2" name="rating" value="2" />
									<label for="star2" title="Kinda bad">2 stars</label> 
								<input type="radio" id="star1" name="rating" value="1" />
									<label for="star1" title="Sucks big time">1 star</label>
							</fieldset>
							<br/>
							<br/>
							<%
								String id = (String) request.getAttribute("id");
							%>
							Description:
							<br />
							<textarea id="description" name="description" type="text" value="" maxlength="255"
								cols="45" rows="5"></textarea>
							<br/><input type="button" value="Go back" maxlength="255" onClick="window.location='collaborations.jsp'"/>
							<input type="button" value="Leave a feedback!" onClick="checkNotEmpty(document.getElementById('description'), '<%=id%>');"/>
								
						</div>
					</div>
					<div style="clear: both;">&nbsp;</div>
				</div>
				<!-- end #content -->
				<div id="sidebar">
					<ul>
						<li>
						</li>
						
					</ul>
				</div>
				<!-- end #sidebar -->
				<div style="clear: both;">&nbsp;</div>
			</div>
		</div>
	</div>
	<!-- end #page -->
</div>
<div id="footer">
	<p></p>
</div>
<!-- end #footer -->
</body>
</html>